<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>后台班次修改</title>
    <%@include file="common/head.jsp" %>
    <%@include file="common/loginstate.jsp" %>
    <link href="${staticPath}/css/css.css" type=text/css rel=stylesheet>
    <script type="text/javascript" src="${staticPath}/js/popup.js"></script>
    <script type="text/javascript">
        //文件上传
        function upx(id) {
            var pop = new Popup({contentType: 1, isReloadOnClose: false, width: 400, height: 200});
            pop.setContent("contentUrl", "${contextPath}/common/upload/?id=" + id);
            pop.setContent("title", "文件上传");
            pop.build();
            pop.show();
        }

        // 修改班次
        function banciSet() {
            var id = $('#id').val();
			var bianhao  = $("#bianhao").length > 0 ? $('#bianhao').val().trim():null;
			if($("#bianhao").length > 0 && bianhao == "")
			{
				alert("please input:编号");
			    $('#bianhao').focus();
				return false;
			}
			var leibieid=$('#leibieid').val().trim();
			var qishizhan  = $("#qishizhan").length > 0 ? $('#qishizhan').val().trim():null;
			if($("#qishizhan").length > 0 && qishizhan == "")
			{
				alert("please input:起始站");
			    $('#qishizhan').focus();
				return false;
			}
			var zhongdianzhan  = $("#zhongdianzhan").length > 0 ? $('#zhongdianzhan').val().trim():null;
			if($("#zhongdianzhan").length > 0 && zhongdianzhan == "")
			{
				alert("please input:终点站");
			    $('#zhongdianzhan').focus();
				return false;
			}
			var qishishijian  = $("#qishishijian").length > 0 ? $('#qishishijian').val().trim():null;
			if($("#qishishijian").length > 0 && qishishijian == "")
			{
				alert("please input:起始时间");
			    $('#qishishijian').focus();
				return false;
			}
			var daodashijian  = $("#daodashijian").length > 0 ? $('#daodashijian').val().trim():null;
			if($("#daodashijian").length > 0 && daodashijian == "")
			{
				alert("please input:到达时间");
			    $('#daodashijian').focus();
				return false;
			}
			var riqi  = $("#riqi").length > 0 ? $('#riqi').val().trim():null;
			if($("#riqi").length > 0 && riqi == "")
			{
				alert("please input:日期");
			    $('#riqi').focus();
				return false;
			}
			var jiage  = $("#jiage").length > 0 ? $('#jiage').val().trim():null;
			if($("#jiage").length > 0 && jiage == "")
			{
				alert("please input:价格");
			    $('#jiage').focus();
				return false;
			}
			var shuliang  = $("#shuliang").length > 0 ? $('#shuliang').val().trim():null;
			if($("#shuliang").length > 0 && shuliang == "")
			{
				alert("please input:票数");
			    $('#shuliang').focus();
				return false;
			}
			var beizhu  = $("#beizhu").length > 0 ? $('#beizhu').val().trim():null;
			if($("#beizhu").length > 0 && beizhu == "")
			{
				alert("please input:备注");
			    $('#beizhu').focus();
				return false;
			}

            var param = {
                'id': id,
				'bianhao':bianhao,
				'leibieid':leibieid,
				'qishizhan':qishizhan,
				'zhongdianzhan':zhongdianzhan,
				'qishishijian':qishishijian,
				'daodashijian':daodashijian,
				'riqi':riqi,
				'jiage':jiage,
				'shuliang':shuliang,
				'beizhu':beizhu,

            };
            $.ajax({
                type: 'post',
                url: '${basePath}/banciAddOrUpdate',
                dataType: "json",
                contentType:"application/json",
                data : JSON.stringify(param),
                success: function (resp) {
                    if (resp.success) {
                        alert("修改成功！");
                        //window.location.href = "${contextPath}/banciMana";
                    } else {
                        alert(resp.message);
                    }
                }
            });
        }
    </script>
</head>


<body>

<form name="formAdd" id="formAdd">
    <table width="98%" align="center" border="0" cellpadding="4" cellspacing="1" bgcolor="#CBD8AC"
           style="margin-bottom:8px">
        <tr bgcolor="#EEF4EA">
            <td colspan="3" background="${staticPath}/img/wbg.gif" class='title'><span>&nbsp;班次修改</span>
            </td>
        </tr>
		<tr align='center' bgcolor="#FFFFFF" height="22">
			<td width="10%" bgcolor="#FFFFFF" align="right">
				编号:
			</td>
            <td width="90%" bgcolor="#FFFFFF" align="left">
                <input type="text" name="bianhao" id="bianhao" value="${banci.bianhao }" size="90px"/>
            </td>

		</tr>
		<tr align='center' bgcolor="#FFFFFF" height="22">
			<td width="10%" bgcolor="#FFFFFF" align="right">
				类别:
			</td>
            <td width="90%" bgcolor="#FFFFFF" align="left">
                <select name="leibieid" id="leibieid" style="  border:solid 1px #000000; color:#666666">
                    <option value="${banci.leibie.id }">${banci.leibie.mingcheng }</option>
                </select>
            </td>
            <script type="text/javascript">
                $.get(basePath + '/leibieAll/', function(resp) {
                    if (resp.success) {
                        if(resp.data!=null){
                            var list = resp.data;
                            for(var i=0; i<list.length; i++){
                                var info = list[i];
                                $("#leibieid").append("<option value='"+info.id+"' >" + info.mingcheng + "</option>");
                            }
                        }
                    }else {
                        alert(resp.message);
                    }
                });
            </script>

		</tr>
		<tr align='center' bgcolor="#FFFFFF" height="22">
			<td width="10%" bgcolor="#FFFFFF" align="right">
				起始站:
			</td>
            <td width="90%" bgcolor="#FFFFFF" align="left">
                <input type="text" name="qishizhan" id="qishizhan" value="${banci.qishizhan }" size="90px"/>
            </td>

		</tr>
		<tr align='center' bgcolor="#FFFFFF" height="22">
			<td width="10%" bgcolor="#FFFFFF" align="right">
				终点站:
			</td>
            <td width="90%" bgcolor="#FFFFFF" align="left">
                <input type="text" name="zhongdianzhan" id="zhongdianzhan" value="${banci.zhongdianzhan }" size="90px"/>
            </td>

		</tr>
		<tr align='center' bgcolor="#FFFFFF" height="22">
			<td width="10%" bgcolor="#FFFFFF" align="right">
				起始时间:
			</td>
            <td width="90%" bgcolor="#FFFFFF" align="left">
                <input type="text" name="qishishijian" id="qishishijian" style="border:1px solid #cccccc;" readonly="readonly" size="20px" value="${banci.qishishijian}" />
            </td>

		</tr>
		<tr align='center' bgcolor="#FFFFFF" height="22">
			<td width="10%" bgcolor="#FFFFFF" align="right">
				到达时间:
			</td>
            <td width="90%" bgcolor="#FFFFFF" align="left">
                <input type="text" name="daodashijian" id="daodashijian" style="border:1px solid #cccccc;" readonly="readonly" size="20px" value="${banci.daodashijian}" />
            </td>

		</tr>
		<tr align='center' bgcolor="#FFFFFF" height="22">
			<td width="10%" bgcolor="#FFFFFF" align="right">
				日期:
			</td>
            <td width="90%" bgcolor="#FFFFFF" align="left">
                <input type="text" name="riqi" id="riqi" style="border:1px solid #cccccc;" class="Wdate" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" onClick="WdatePicker({'dateFmt':'yyyy-MM-dd'})" size="15px" value="${banci.riqi}" />
            </td>

		</tr>
		<tr align='center' bgcolor="#FFFFFF" height="22">
			<td width="10%" bgcolor="#FFFFFF" align="right">
				价格:
			</td>
            <td width="90%" bgcolor="#FFFFFF" align="left">
                <input type="text" name="jiage" id="jiage" value="${banci.jiage }" size="90px"/>
            </td>

		</tr>
		<tr align='center' bgcolor="#FFFFFF" height="22">
			<td width="10%" bgcolor="#FFFFFF" align="right">
				票数:
			</td>
            <td width="90%" bgcolor="#FFFFFF" align="left">
                <input type="text" name="shuliang" id="shuliang" value="${banci.shuliang }" size="90px"/>
            </td>

		</tr>
		<tr align='center' bgcolor="#FFFFFF" height="22">
			<td width="10%" bgcolor="#FFFFFF" align="right">
				备注:
			</td>
            <td width="90%" bgcolor="#FFFFFF" align="left">
                <input type="text" name="beizhu" id="beizhu" value="${banci.beizhu }" size="90px"/>
            </td>

		</tr>

        <tr align='center' bgcolor="#FFFFFF" height="22">
            <td width="10%" bgcolor="#FFFFFF" align="right">&nbsp;</td>
            <td width="90%" bgcolor="#FFFFFF" align="left">
                <input type="hidden" id="id" name="id" value="${banci.id}"/>
                <input type="button" value="提交" onclick="banciSet();"/>&nbsp;
                <input type="button" value="返回" onClick="javascript:history.back()"/>
                <input type="reset" value="重置"/>&nbsp;
            </td>
        </tr>
    </table>
</form>

</body>
</html>


